<template>
  <div class="debug-info">
    <n-card title="调试信息" size="large">
      <n-space vertical size="large">
        
        <!-- 工作区信息 -->
        <n-card title="工作区信息" size="small">
          <n-space vertical size="small">
            <div><strong>工作区数量:</strong> {{ workspaceStore.workspaces.length }}</div>
            <div><strong>当前工作区ID:</strong> {{ workspaceStore.currentWorkspaceId || '无' }}</div>
            <div><strong>当前工作区:</strong> {{ currentWorkspaceInfo }}</div>
            
            <n-divider />
            
            <div><strong>所有工作区:</strong></div>
            <n-list>
              <n-list-item v-for="workspace in workspaceStore.workspaces" :key="workspace.id">
                <n-thing>
                  <template #header>
                    <n-space align="center">
                      <span>{{ workspace.name }}</span>
                      <n-tag :type="workspace.id === workspaceStore.currentWorkspaceId ? 'success' : 'default'">
                        {{ workspace.id === workspaceStore.currentWorkspaceId ? '当前' : '其他' }}
                      </n-tag>
                    </n-space>
                  </template>
                  <template #description>
                    <div>ID: {{ workspace.id }}</div>
                    <div>描述: {{ workspace.description }}</div>
                    <div>类型: {{ workspace.type }}</div>
                    <div>状态: {{ workspace.status }}</div>
                    <div>创建时间: {{ workspace.createTime }}</div>
                    <div>文件路径: {{ workspace.filePath }}</div>
                    <div>提取数据长度: {{ workspace.extractedData ? workspace.extractedData.length : 0 }}</div>
                  </template>
                </n-thing>
              </n-list-item>
            </n-list>
          </n-space>
        </n-card>

        <!-- 文件数据信息 -->
        <n-card title="文件数据信息" size="small">
          <n-space vertical size="small">
            <div><strong>内存使用情况:</strong></div>
            <n-space vertical size="small">
              <div>总大小: {{ memoryUsage.totalSizeMB }} MB</div>
              <div>工作区数量: {{ memoryUsage.workspaceCount }}</div>
            </n-space>
            
            <n-divider />
            
            <div><strong>各工作区文件数据:</strong></div>
            <n-list>
              <n-list-item v-for="workspace in workspaceStore.workspaces" :key="workspace.id">
                <n-thing>
                  <template #header>
                    <n-space align="center">
                      <span>{{ workspace.name }}</span>
                      <n-tag :type="fileDataStore.hasFileData(workspace.id) ? 'success' : 'error'">
                        {{ fileDataStore.hasFileData(workspace.id) ? '有数据' : '无数据' }}
                      </n-tag>
                    </n-space>
                  </template>
                  <template #description>
                    <div>工作区ID: {{ workspace.id }}</div>
                    <div>文件数据大小: {{ getFileDataSize(workspace.id) }}</div>
                    <div>文件数据预览: {{ getFileDataPreview(workspace.id) }}</div>
                  </template>
                </n-thing>
              </n-list-item>
            </n-list>
          </n-space>
        </n-card>

        <!-- 解压文件列表 -->
        <n-card title="解压文件列表" size="small">
          <n-space vertical size="small">
            <div>
              <strong>当前工作区ID:</strong> {{ workspaceStore.currentWorkspaceId || '无' }}
            </div>
            <div>
              <strong>已解析文件数:</strong> {{ filteredFileList.length }}
              <span v-if="filteredFileList.length > fileListLimit">（显示前 {{ fileListLimit }} 条）</span>
            </div>
            <n-input v-model:value="fileListFilter" placeholder="输入关键字过滤（包含匹配）" />
            <n-list>
              <n-list-item v-for="(path, idx) in filteredFileList.slice(0, fileListLimit)" :key="path">
                <n-thing>
                  <template #header>
                    <n-space align="center" justify="space-between" style="width: 100%">
                      <span>{{ idx + 1 }}. {{ path }}</span>
                      <n-button size="tiny" @click="previewFile(path)">预览</n-button>
                    </n-space>
                  </template>
                </n-thing>
              </n-list-item>
            </n-list>
          </n-space>
        </n-card>

        <!-- 转储文件调试 -->
        <n-card title="转储文件调试" size="small">
          <n-space vertical size="small">
            <div>
              <strong>调试转储文件解压数据</strong>
            </div>
            <n-space>
              <n-button @click="debugDumpFile('app', 1)" type="primary" size="small">
                调试 app.log.1.gz
              </n-button>
              <n-button @click="debugDumpFile('framework', 1)" type="primary" size="small">
                调试 framework.log.1.gz
              </n-button>
              <n-button @click="debugDumpFile('operation', 1)" type="primary" size="small">
                调试 operation.log.1.gz
              </n-button>
            </n-space>
            
            <n-divider />
            
                        <n-space>
              <n-button @click="forceClearCache" type="warning" size="small">
                强制清除组件日志缓存
              </n-button>
              <n-button @click="testComponentLogLoad" type="info" size="small">
                测试 account 组件加载
              </n-button>
              <n-button @click="debugIndexedDB" type="error" size="small">
                调试 IndexedDB 内容
              </n-button>
              <n-button @click="testSpecificAccountLog" type="primary" size="small">
                测试特定 account 日志
              </n-button>
              </n-space>
            
            <div v-if="dumpDebugInfo.show">
              <n-divider />
              <div><strong>{{ dumpDebugInfo.title }}</strong></div>
              <div>文件大小: {{ dumpDebugInfo.size }}</div>
              <div>行数: {{ dumpDebugInfo.lineCount }}</div>
              <div>包含 account 的行数: {{ dumpDebugInfo.accountLines }}</div>
              
              <n-divider />
              <div><strong>前20行内容预览:</strong></div>
              <n-input
                v-model:value="dumpDebugInfo.preview" 
                type="textarea"
                :rows="10"
                readonly
                style="font-family: monospace; font-size: 12px;"
              />
              
              <div v-if="dumpDebugInfo.accountSample.length > 0">
                <n-divider />
                <div><strong>包含 account 的前10行:</strong></div>
                <n-input 
                  v-model:value="dumpDebugInfo.accountPreview" 
                  type="textarea" 
                  :rows="8"
                  readonly
                  style="font-family: monospace; font-size: 12px;"
              />
            </div>
            </div>
          </n-space>
        </n-card>

        <!-- 本地存储信息 -->
        <n-card title="本地存储信息" size="small">
          <n-space vertical size="small">
            <div><strong>localStorage 工作区:</strong></div>
            <n-input 
              v-model:value="localStorageWorkspaces" 
              type="textarea" 
              :rows="5"
              readonly
            />
            
            <div><strong>localStorage 当前工作区ID:</strong></div>
            <n-input 
              v-model:value="localStorageCurrentWorkspaceId" 
              readonly
            />
            
            <div><strong>localStorage 文件数据:</strong></div>
            <n-input 
              v-model:value="localStorageFileData" 
              type="textarea" 
              :rows="5"
              readonly
            />
                    </n-space>
                  </n-card>

        <!-- 操作按钮 -->
        <n-card title="操作" size="small">
          <n-space>
            <n-button @click="refreshData" type="primary">
              刷新数据
            </n-button>
            <n-button @click="clearAllData" type="warning">
              清理所有数据
            </n-button>
            <n-button @click="testFileData" type="info">
              测试文件数据
            </n-button>
          </n-space>
                 </n-card>

        <n-card title="文件数据存储调试" class="debug-card">
          <n-space vertical>
            <n-text>当前工作区ID: {{ currentWorkspaceId }}</n-text>
            <n-text>文件数据状态: {{ fileDataStatus }}</n-text>
            <n-text>内存使用: {{ memoryUsage.totalSizeMB }} MB</n-text>
            <n-text>工作区数量: {{ memoryUsage.workspaceCount }}</n-text>
            
            <!-- 添加文件大小检查 -->
            <n-divider />
            <n-text strong>文件大小检查:</n-text>
            <n-text>当前工作区文件大小: {{ currentFileSize }} KB</n-text>
            <n-text>是否超过5MB限制: {{ isOverSizeLimit ? '是' : '否' }}</n-text>
            <n-text>是否会被分块处理: {{ willBeChunked ? '是' : '否' }}</n-text>
            
            <!-- 添加分块处理状态 -->
            <n-divider />
            <n-text strong>分块处理状态:</n-text>
            <n-text>分块数量: {{ chunkCount }}</n-text>
            <n-text>实际存储大小: {{ actualStoredSize }} MB</n-text>
            
            <n-button @click="testFileDataOperations" type="primary" size="small">
              测试文件数据操作
            </n-button>
          </n-space>
        </n-card>

      </n-space>
    </n-card>
  </div>
</template>

<script setup lang="ts">
import { ref, computed, onMounted } from 'vue'
import { useWorkspaceStore } from '../stores/workspace'
import { useFileDataStore } from '../stores/fileData'
import { getDumpLogData } from '../utils/archiveDb'

const workspaceStore = useWorkspaceStore()
const fileDataStore = useFileDataStore()

// 响应式数据
const localStorageWorkspaces = ref('')
const localStorageCurrentWorkspaceId = ref('')
const localStorageFileData = ref('')

// 计算属性
const currentWorkspaceInfo = computed(() => {
  const current = workspaceStore.currentWorkspace
  if (!current) return '无'
  return `${current.name} (${current.id})`
})

const memoryUsage = computed(() => {
  return fileDataStore.getMemoryUsage()
})

// 添加新的计算属性
const currentWorkspaceId = computed(() => {
  return workspaceStore.currentWorkspaceId || '无'
})

const fileDataStatus = computed(() => {
  const current = workspaceStore.currentWorkspace
  if (!current) return '无当前工作区'
  return fileDataStore.hasFileData(current.id) ? '有数据' : '无数据'
})

const currentFileSize = computed(() => {
  const current = workspaceStore.currentWorkspace
  if (!current) return 0
  const size = fileDataStore.getFileSize(current.id)
  return size < 1024 ? size : (size / 1024).toFixed(2)
})

const isOverSizeLimit = computed(() => {
  const current = workspaceStore.currentWorkspace
  if (!current) return false
  const size = fileDataStore.getFileSize(current.id)
  return size > 5 * 1024 * 1024 // 5MB
})

const willBeChunked = computed(() => {
  return isOverSizeLimit.value
})

const chunkCount = computed(() => {
  const current = workspaceStore.currentWorkspace
  if (!current) return 0
  const size = fileDataStore.getFileSize(current.id)
  if (size <= 5 * 1024 * 1024) return 1
  return Math.ceil(size / (1024 * 1024)) // 每块1MB
})

const actualStoredSize = computed(() => {
  const current = workspaceStore.currentWorkspace
  if (!current) return 0
  const size = fileDataStore.getFileSize(current.id)
  if (size <= 5 * 1024 * 1024) return (size / 1024 / 1024).toFixed(2)
  // 如果超过5MB，只存储前3块
  const storedSize = Math.min(size, 3 * 1024 * 1024)
  return (storedSize / 1024 / 1024).toFixed(2)
})

// 解压文件列表相关状态
const fileListFilter = ref('')
const fileListLimit = 300

// 转储文件调试状态
const dumpDebugInfo = ref({
  show: false,
  title: '',
  size: '',
  lineCount: 0,
  accountLines: 0,
  preview: '',
  accountSample: [] as string[],
  accountPreview: ''
})

// 解析当前工作区的“路径列表”，路径行以 dump_info/ 开头
const parsedFileList = computed(() => {
  const current = workspaceStore.currentWorkspace
  if (!current) return [] as string[]
  const data = fileDataStore.getFileData(current.id)
  if (!data) return []
  const lines = data.split('\n')
  const paths: string[] = []
  for (const line of lines) {
    const trimmed = line.trim()
    if (trimmed.startsWith('dump_info/')) {
      paths.push(trimmed)
    }
  }
  return Array.from(new Set(paths))
})

const filteredFileList = computed(() => {
  const keyword = fileListFilter.value.trim()
  if (!keyword) return parsedFileList.value
  const lower = keyword.toLowerCase()
  return parsedFileList.value.filter(p => p.toLowerCase().includes(lower))
})

function previewFile(path: string) {
  const current = workspaceStore.currentWorkspace
  if (!current) {
    alert('无当前工作区')
    return
  }
  const data = fileDataStore.getFileData(current.id)
  if (!data) {
    alert('当前工作区无文件数据')
    return
  }
  const lines = data.split('\n')
  let collecting = false
  const content: string[] = []
  for (const line of lines) {
    const trimmed = line.trim()
    if (!collecting) {
      if (trimmed === path) {
        collecting = true
        continue
      }
    } else {
      if (trimmed.startsWith('dump_info/') && trimmed !== path) {
        break
      }
      content.push(line)
    }
  }
  const text = content.join('\n')
  const preview = text.length > 2000 ? text.slice(0, 2000) + '...' : text
  alert(`路径: ${path}\n\n内容预览:\n${preview}`)
}

// 方法
function getFileDataSize(workspaceId: string): string {
  const size = fileDataStore.getFileSize(workspaceId)
  if (size === 0) return '0 字符'
  if (size < 1024) return `${size} 字符`
  if (size < 1024 * 1024) return `${(size / 1024).toFixed(2)} KB`
  return `${(size / 1024 / 1024).toFixed(2)} MB`
}

function getFileDataPreview(workspaceId: string): string {
  const data = fileDataStore.getFileData(workspaceId)
  if (!data) return '无数据'
  if (data.length > 200) {
    return data.substring(0, 200) + '...'
  }
  return data
}

function refreshData() {
  // 刷新本地存储信息
  try {
    localStorageWorkspaces.value = localStorage.getItem('workspaces') || '无数据'
    localStorageCurrentWorkspaceId.value = localStorage.getItem('currentWorkspaceId') || '无数据'
    localStorageFileData.value = localStorage.getItem('fileDataStore') || '无数据'
  } catch (error) {
    console.error('刷新数据失败:', error)
  }
}

function clearAllData() {
  if (confirm('确定要清理所有数据吗？')) {
    try {
      fileDataStore.clearAllFileData()
      localStorage.removeItem('workspaces')
      localStorage.removeItem('currentWorkspaceId')
      localStorage.removeItem('fileDataStore')
      refreshData()
      alert('数据已清理')
    } catch (error) {
      console.error('清理数据失败:', error)
      alert('清理数据失败: ' + error)
    }
  }
}

function testFileData() {
  const currentWorkspace = workspaceStore.currentWorkspace
  if (!currentWorkspace) {
    alert('请先选择工作区')
    return
  }

  const fileData = fileDataStore.getFileData(currentWorkspace.id)
  if (fileData) {
    alert(`文件数据获取成功！\n大小: ${fileData.length} 字符\n预览: ${fileData.substring(0, 100)}...`)
  } else {
    alert('文件数据获取失败！')
  }
}

// 添加新的测试方法
function testFileDataOperations() {
  const currentWorkspace = workspaceStore.currentWorkspace
  if (!currentWorkspace) {
    alert('请先选择工作区')
    return
  }

  try {
    // 测试设置文件数据
    const testData = '这是一个测试文件数据，用于验证文件数据存储功能是否正常工作。' + 'x'.repeat(1000)
    fileDataStore.setFileData(currentWorkspace.id, testData)
    
    // 测试获取文件数据
    const retrievedData = fileDataStore.getFileData(currentWorkspace.id)
    
    if (retrievedData && retrievedData === testData) {
      alert(`文件数据操作测试成功！\n设置的数据长度: ${testData.length}\n获取的数据长度: ${retrievedData.length}`)
    } else {
      alert('文件数据操作测试失败！数据不匹配')
    }
  } catch (error) {
    alert(`文件数据操作测试失败: ${error}`)
  }
}

// 调试转储文件
async function debugDumpFile(dumpType: 'app' | 'framework' | 'operation', index: number) {
  const workspaceId = workspaceStore.currentWorkspaceId
  if (!workspaceId) {
    console.error('[Debug] 没有当前工作区')
    return
  }

  console.log(`[Debug] 开始调试 ${dumpType}.log.${index}.gz`)
  
  try {
    const dumpData = await getDumpLogData(workspaceId, dumpType, index)
    
    if (!dumpData) {
      dumpDebugInfo.value = {
        show: true,
        title: `${dumpType}.log.${index}.gz 调试信息`,
        size: '未找到数据',
        lineCount: 0,
        accountLines: 0,
        preview: '该转储文件未找到或未解压',
        accountSample: [],
        accountPreview: ''
      }
      console.log(`[Debug] ${dumpType}.log.${index}.gz 未找到数据`)
      return
    }

    const lines = dumpData.split('\n')
    const accountLines = lines.filter(line => line.toLowerCase().includes('account'))
    
    console.log(`[Debug] ${dumpType}.log.${index}.gz 解压数据:`)
    console.log(`- 文件大小: ${(dumpData.length / 1024 / 1024).toFixed(2)} MB`)
    console.log(`- 总行数: ${lines.length}`)
    console.log(`- 包含 account 的行数: ${accountLines.length}`)
    
    dumpDebugInfo.value = {
      show: true,
      title: `${dumpType}.log.${index}.gz 调试信息`,
      size: `${(dumpData.length / 1024 / 1024).toFixed(2)} MB`,
      lineCount: lines.length,
      accountLines: accountLines.length,
      preview: lines.slice(0, 20).join('\n'),
      accountSample: accountLines.slice(0, 10),
      accountPreview: accountLines.slice(0, 10).join('\n')
    }
    
    // 输出包含 account 的示例行到控制台
    console.log(`[Debug] 包含 account 的前5行示例:`)
    accountLines.slice(0, 5).forEach((line, idx) => {
      console.log(`${idx + 1}: ${line}`)
    })
    
  } catch (error) {
    console.error(`[Debug] 调试 ${dumpType}.log.${index}.gz 失败:`, error)
    dumpDebugInfo.value = {
      show: true,
      title: `${dumpType}.log.${index}.gz 调试信息`,
      size: '读取失败',
      lineCount: 0,
      accountLines: 0,
      preview: `错误: ${error}`,
      accountSample: [],
      accountPreview: ''
    }
  }
}

// 强制清除缓存
function forceClearCache() {
  console.log('[Debug] 强制清除组件日志缓存')
  if (typeof window !== 'undefined' && (window as any).__clearLogCache) {
    (window as any).__clearLogCache('app')
    alert('缓存已清除，组件日志将重新加载')
  } else {
    alert('缓存清除功能不可用')
  }
}

// 测试 account 组件加载
async function testComponentLogLoad() {
  const workspaceId = workspaceStore.currentWorkspaceId
  if (!workspaceId) {
    alert('没有当前工作区')
    return
  }

  console.log('[Debug] 测试 account 组件日志加载')
  
  try {
    // 导入需要的函数
    const { getAllDumpLogs } = await import('../utils/archiveDb')
    
    // 测试查询转储日志
    const dumpLogs = await getAllDumpLogs(workspaceId, 'app')
    console.log(`[Debug] 找到 ${dumpLogs.length} 个转储日志文件`)
    
    let totalAccountLines = 0
    for (const dump of dumpLogs) {
      const lines = dump.data.split('\n')
      const accountLines = lines.filter(line => line.toLowerCase().includes('account'))
      totalAccountLines += accountLines.length
      console.log(`[Debug] 转储文件 ${dump.index}: 总行数 ${lines.length}, account 行数 ${accountLines.length}`)
    }
    
    alert(`转储日志测试完成:\n- 转储文件数: ${dumpLogs.length}\n- 总 account 行数: ${totalAccountLines}`)
    
  } catch (error) {
    console.error('[Debug] 测试失败:', error)
    alert(`测试失败: ${error}`)
  }
}

// 调试 IndexedDB 内容
async function debugIndexedDB() {
  const workspaceId = workspaceStore.currentWorkspaceId
  if (!workspaceId) {
    alert('没有当前工作区')
    return
  }

  console.log('[Debug] 调试 IndexedDB 内容')
  
  try {
    // 打开 IndexedDB - 使用正确的数据库名和存储名
    const dbName = 'LogVision'
    const request = indexedDB.open(dbName, 1)
    
    request.onsuccess = (e: any) => {
      const db = e.target.result
      const tx = db.transaction(['files'], 'readonly')
      const store = tx.objectStore('files')
      const index = store.index('workspaceId')
      
      console.log(`[Debug] 搜索工作区: ${workspaceId}`)
      
      const results: any[] = []
      
      index.openCursor(IDBKeyRange.only(workspaceId)).onsuccess = (e: any) => {
        const cursor = e.target.result
        if (cursor) {
          const rec = cursor.value
          if (rec.path.includes('dump_info/LogDump') || rec.path.includes('app.log')) {
            results.push({
              key: rec.key,
              path: rec.path,
              type: rec.type,
              size: rec.size,
              isBinary: rec.isBinary
            })
          }
          cursor.continue()
        } else {
          console.log(`[Debug] IndexedDB 中找到 ${results.length} 个相关条目:`)
          results.forEach((item, idx) => {
            console.log(`${idx + 1}. ${item.path} (${item.type}, ${item.size} bytes)`)
          })
          
          // 特别查找 app.log.1 相关的条目
          const appLogEntries = results.filter(item => 
            item.path.includes('app.log.1') && !item.path.includes('.gz')
          )
          console.log(`[Debug] 找到 ${appLogEntries.length} 个 app.log.1 相关条目:`)
          appLogEntries.forEach(item => {
            console.log(`- ${item.path}`)
          })
          
          alert(`IndexedDB 调试完成:\n- 总相关条目: ${results.length}\n- app.log.1 条目: ${appLogEntries.length}\n详情请查看控制台`)
        }
      }
    }
    
    request.onerror = (e: any) => {
      console.error('[Debug] 打开 IndexedDB 失败:', e)
      alert('打开 IndexedDB 失败')
    }
    
  } catch (error) {
    console.error('[Debug] IndexedDB 调试失败:', error)
    alert(`IndexedDB 调试失败: ${error}`)
  }
}

// 测试特定的 account 日志
async function testSpecificAccountLog() {
  const workspaceId = workspaceStore.currentWorkspaceId
  if (!workspaceId) {
    alert('没有当前工作区')
    return
  }

  console.log('[Debug] 测试特定 account 日志格式解析')
  
  // 同时检查当前的时间过滤设置
  if (typeof window !== 'undefined' && (window as any).__getTimeFilterInfo) {
    const timeInfo = (window as any).__getTimeFilterInfo()
    console.log('[Debug] 当前时间过滤设置:', timeInfo)
  }
  
  // 从截图中的示例日志
  const testLog = '2025-07-16 02:07:35.702671 account NOTICE: micro_component.lua(135): Startup status has changed, ==> Starting, uptime:77s,'
  
  // 导入解析函数
  const { getAllDumpLogs } = await import('../utils/archiveDb')
  
  try {
    // 1. 测试正则表达式解析
    const regex = /^(\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2}\.\d+)\s+([a-zA-Z_][a-zA-Z0-9_]*)\s+([A-Z]+):\s*(.+)$/
    const match = testLog.match(regex)
    
    console.log('[Debug] 测试日志:', testLog)
    console.log('[Debug] 正则匹配结果:', match)
    
    if (match) {
      console.log('[Debug] 解析结果:')
      console.log('- 时间戳:', match[1])
      console.log('- 组件:', match[2])
      console.log('- 级别:', match[3])
      console.log('- 消息:', match[4])
    }
    
    // 2. 查找转储数据中是否包含这个时间范围的日志
    const dumpLogs = await getAllDumpLogs(workspaceId, 'app')
    console.log(`[Debug] 转储文件数量: ${dumpLogs.length}`)
    
    for (const dump of dumpLogs) {
      const lines = dump.data.split('\n')
      console.log(`[Debug] 转储文件 ${dump.index} 总行数: ${lines.length}`)
      
      // 查找包含 "2025-07-16 02:07:35" 的行
      const targetTimeLines = lines.filter(line => line.includes('2025-07-16 02:07:35'))
      console.log(`[Debug] 包含目标时间的行数: ${targetTimeLines.length}`)
      
      // 查找包含 "account" 组件的行
      const accountLines = lines.filter(line => {
        const regex = /^(\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2}\.\d+)\s+account\s+([A-Z]+):/
        return regex.test(line)
      })
      console.log(`[Debug] account 组件日志行数: ${accountLines.length}`)
      
      if (accountLines.length > 0) {
        console.log('[Debug] 前5条 account 组件日志:')
        accountLines.slice(0, 5).forEach((line, idx) => {
          console.log(`${idx + 1}. ${line}`)
        })
      }
      
      // 查找包含目标时间戳的 account 日志
      const targetAccountLog = lines.find(line => line.includes('2025-07-16 02:07:35.702671 account'))
      if (targetAccountLog) {
        console.log('[Debug] 找到目标 account 日志:', targetAccountLog)
      } else {
        console.log('[Debug] 未找到目标 account 日志')
      }
    }
    
    alert('特定 account 日志测试完成，请查看控制台输出')
    
  } catch (error) {
    console.error('[Debug] 测试失败:', error)
    alert(`测试失败: ${error}`)
  }
}

// 组件挂载时刷新数据
onMounted(() => {
  refreshData()
})
</script>

<style scoped>
.debug-info {
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
}

.n-list-item {
  margin-bottom: 10px;
}
</style> 